﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RouteTiming.SLClient.DynamicModel.Helpers
{
    public class DynamicContextEventArgs : EventArgs
    {
        public string Message { get; set; }
    }

    public class OnErrorEventArgs : DynamicContextEventArgs
    {
    }

    public class OnWarningEventArgs : DynamicContextEventArgs
    {
    }

    public static class EventHelpers
    {
        public static void Raise(this EventHandler evt, object sender)
        {
            var copyEvt = evt;
            if (copyEvt != null)
                copyEvt(sender, null);
        }

        public static void Raise<T>(this EventHandler<T> evt, object sender, string msg)
            where T : DynamicContextEventArgs, new()
        {
            var copyEvt = evt;
            if (copyEvt != null)
                copyEvt(sender, new T{Message = msg});
        }
    }

}
